package com.ling.dataStructures.hash_table.__test__;

import com.ling.dataStructures.hash_table.HashMap01;
import com.ling.dataStructures.hash_table.HashMap02BySeparateChaining;
import com.ling.dataStructures.hash_table.HashMap03ByOpenAddressing;
import com.ling.dataStructures.hash_table.Map;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author: ling007
 * @date: 2025/2/6 16:29
 * @description:
 */

public class HashTableTest {

    private final Logger logger = LoggerFactory.getLogger(HashTableTest.class);


    @Test
    public void test_hashMap01() {
        Map<String, String> map = new HashMap01<>();
        map.put("01", "花花");
        map.put("05", "豆豆");
        logger.debug("碰撞前 key：{} value：{}", "01", map.get("01"));

        // 下标碰撞
        map.put("09", "蛋蛋");
        map.put("12", "苗苗");
        logger.debug("碰撞前 key：{} value：{}", "01", map.get("01"));
    }

    @Test
    public void test_hashMap02() {
        Map<String, String> map = new HashMap02BySeparateChaining<>();
        map.put("01", "花花");
        map.put("05", "豆豆");
        logger.info("碰撞前 key：{} value：{}", "01", map.get("01"));

        // 下标碰撞
        map.put("09", "蛋蛋");
        map.put("12", "苗苗");
        logger.info("碰撞前 key：{} value：{}", "01", map.get("01"));
    }


    @Test
    public void test_hashMap03() {
        Map<String, String> map = new HashMap03ByOpenAddressing<>();
        map.put("01", "花花");
        map.put("05", "豆豆");
        logger.info("碰撞前 key：{} value：{}", "01", map.get("01"));

        // 下标碰撞
        map.put("09", "蛋蛋");
        map.put("12", "苗苗");
        logger.info("碰撞前 key：{} value：{}", "01", map.get("01"));

        logger.info("数据结构：{}", map);
    }

}
